package com.lefeng.cockpit.datax.dao.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.lefeng.cockpit.common.bean.po.job.JobLogReport;
import com.lefeng.cockpit.datax.dao.JobInfoReportDao;
import com.lefeng.cockpit.datax.dao.mapper.JobLogReportMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class JobInfoReportDaoImpl implements JobInfoReportDao {

    @Resource
    private JobLogReportMapper jobLogReportMapper;

    @Override
    public int update(JobLogReport jobLogReport) {
        LambdaUpdateWrapper<JobLogReport> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(JobLogReport::getTriggerDay, jobLogReport.getTriggerDay()); // WHERE 条件
        updateWrapper.set(JobLogReport::getRunningCount, jobLogReport.getRunningCount()); // 更新值
        updateWrapper.set(JobLogReport::getSucCount, jobLogReport.getSucCount()); // 更新值
        updateWrapper.set(JobLogReport::getFailCount, jobLogReport.getFailCount()); // 更新值
        return jobLogReportMapper.update(jobLogReport, updateWrapper);
    }

    @Override
    public void save(JobLogReport jobLogReport) {
        jobLogReportMapper.insert(jobLogReport);
    }
}
